package com.newhis.common;

import com.newhis.BizException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class LogHelper {
    private static Logger logger = LoggerFactory.getLogger(LogHelper.class);

    @Autowired
    private DBSqlHelper dbSqlHelper;

    /**
     * INFO级别一般日志
     * @param content
     */
    public void info(String content) {
        logger.info(content);
    }

    /**
     * DEBUG级别一般日志
     * @param content
     */
    public void debug(String content) {
        logger.debug(content);
    }

    /**
     * WARN级别一般日志
     * @param content
     */
    public void warn(String content) {
        logger.warn(content);
    }

    /**
     * ERROR级别一般日志
     * @param content
     */
    public void error(String content) {
        logger.error(content);
    }

    /**
     * 异常触发日志
     * @param ex
     */
    public void bizException(BizException ex) {
        logger.error(ex.getErrorMsg());
        dbSqlHelper.recExceptionLog(ex);
    }

    /**
     * 服务监视触发日志
     * @param content
     */
    public void bizMonitor(String header, String content) {
        logger.debug(content);
        dbSqlHelper.recMonitorLog(header, content);
    }
}
